home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-07-15 | 7.0 KB | 228 lines | [TEXT/MPS ] |
- //----------------------------------------------------------------------------------------
- // UVolume.cp
- // ETO20 MacApp 3.3.1, MPW 3.4.1
- // Copyright ©1996 Conrad Kopala
- // Twist Down Lists version 2.0a0 7/15/96
- //----------------------------------------------------------------------------------------
-
- #ifndef __UVOLUME__
- #include "UVolume.h"
- #endif
-
- #ifndef __UTWISTDOWNGLOBALS__
- #include "UTwistDownGlobals.h"
- #endif
-
- // MacApp
- //None
-
- // Toolbox
- //None
-
- // ANSI
- //None
- //========================================================================================
- // GLOBAL Procedures
- //========================================================================================
- #undef Inherited
-
- //----------------------------------------------------------------------------------------
- // NewVolume:
- //----------------------------------------------------------------------------------------
- #pragma segment MAFileOpen
-
- TVolume* NewVolume(OSType itsCreator)
- {
- TVolume * theVolume;
-
- theVolume = new TVolume;
- theVolume -> IVolume(itsCreator);
- return theVolume;
- }
- //========================================================================================
- // CLASS TVolume
- //========================================================================================
- #undef Inherited
- #define Inherited TObject
-
- #pragma segment MAFileOpen
- MA_DEFINE_CLASS_M1(TVolume, Inherited);
-
- //----------------------------------------------------------------------------------------
- // TVolume constructor
- //----------------------------------------------------------------------------------------
- #pragma segment MAFileOpen
- TVolume::TVolume()
- {
- fFileSpec.vRefNum = 0;
- fFileSpec.parID = 0;
- fFileSpec.name[0] = '\0';
-
- fFileType = 'disk';
- fCreator = '\?\?\?\?';
-
- #if qDebug
- this -> PrintAppConstructorClassInfo();
- #endif
- }
- //----------------------------------------------------------------------------------------
- // TVolume::IVolume:
- //----------------------------------------------------------------------------------------
- #pragma segment MAFileOpen
- void TVolume::IVolume(OSType itsCreator)
- {
- this -> IObject();
-
- fCreator = itsCreator;
-
- }
- //----------------------------------------------------------------------------------------
- // TVolume destructor
- //----------------------------------------------------------------------------------------
- #pragma segment MAFileClose
- TVolume::~TVolume()
- {
- #if qDebug
- this -> PrintAppDestructorClassInfo();
- #endif
- }
- //----------------------------------------------------------------------------------------
- // TVolume::IsHFSVolume:
- //----------------------------------------------------------------------------------------
- #pragma segment MAFileNonRes
- Boolean TVolume::IsHFSVolume()
- {
- Boolean result = FALSE;
- HVolumeParam pb;
-
- BlockSet((Ptr) & pb, sizeof(HVolumeParam), 0x00);
-
- pb.ioVRefNum = this -> GetVolRefNum();;
- pb.ioVolIndex = 0;
-
- FailOSErr(PBHGetVInfoSync((HParmBlkPtr)&pb));
-
- short volType = pb.ioVSigWord;
-
- if (volType == 0x4244)
- result = TRUE;
-
- return result;
- }
- //----------------------------------------------------------------------------------------
- // TVolume::Specify:
- //----------------------------------------------------------------------------------------
- #pragma segment MAFileNonRes
- void TVolume::Specify(const FSSpec& theFile)
- {
- fFileSpec = theFile;
- }
- //----------------------------------------------------------------------------------------
- // TVolume::SpecifyWithStandardFileReply:
- //----------------------------------------------------------------------------------------
- #pragma segment MAFileNonRes
- void TVolume::SpecifyWithStandardFileReply(const StandardFileReply& itsReply)
- {
- this -> Specify(itsReply.sfFile);
- }
- //----------------------------------------------------------------------------------------
- // TVolume::SpecifyWithSFReply:
- //----------------------------------------------------------------------------------------
- #pragma segment MAFileNonRes
- OSErr TVolume::SpecifyWithSFReply(const SFReply& itsReply)
- {
-
- OSErr theErr = this -> SpecifyWithTrio(itsReply.vRefNum, 0, itsReply.fName);
-
- return theErr;
- }
- //----------------------------------------------------------------------------------------
- // TVolume::SpecifyWithAlias:
- //----------------------------------------------------------------------------------------
- #pragma segment MAFileNonRes
- OSErr TVolume::SpecifyWithAlias(AliasHandle alias)
- {
- FSSpec theFileSpec;
- Boolean dontCare;
-
- OSErr theErr = ResolveAlias((FSSpecPtr)NULL, alias, &theFileSpec, &dontCare);
- if (theErr == noErr)
- this -> Specify(theFileSpec);
-
- return theErr;
- }
- //----------------------------------------------------------------------------------------
- // TVolume::SpecifyWithTrio:
- //----------------------------------------------------------------------------------------
- #pragma segment MAFileNonRes
- OSErr TVolume::SpecifyWithTrio(short volRefNum, long dirID, const CStr63& name)
- {
- FSSpec theFileSpec;
- OSErr theErr = noErr;
-
- if ((theErr = FSMakeFSSpec(volRefNum, dirID, name, &theFileSpec)) == fnfErr)
- theErr = noErr; // The file may not yet exist
-
- if (theErr == noErr)
- this->Specify(theFileSpec);
- return theErr;
- }
- //----------------------------------------------------------------------------------------
- // TVolume::GetAlias:
- //----------------------------------------------------------------------------------------
- #pragma segment MAFileNonRes
- OSErr TVolume::GetAlias(AliasHandle& alias)
- {
- FSSpec theFileSpec = fFileSpec;
- return NewAliasMinimal(&theFileSpec, &alias);
- }
- //----------------------------------------------------------------------------------------
- // TVolume::GetCatInfo:
- //----------------------------------------------------------------------------------------
- #pragma segment MAFileNonRes
- OSErr TVolume::GetCatInfo(CInfoPBRec& cInfo)
- {
- CStr63 itsName;
-
- itsName = fFileSpec.name;
- cInfo.hFileInfo.ioNamePtr = (StringPtr) itsName;
- cInfo.hFileInfo.ioVRefNum = fFileSpec.vRefNum;
- cInfo.hFileInfo.ioFDirIndex = 0;
- cInfo.hFileInfo.ioDirID = fFileSpec.parID;
- OSErr err = PBGetCatInfoSync(&cInfo);
- cInfo.hFileInfo.ioNamePtr = NULL;
- return err;
- }
- //----------------------------------------------------------------------------------------
- // TVolume::GetName:
- //----------------------------------------------------------------------------------------
- #pragma segment MAFileRes
- void TVolume::GetName(CStr31& name)
- {
- name = fFileSpec.name;
- }
- //----------------------------------------------------------------------------------------
- // TVolume::GetVolRefNum:
- //----------------------------------------------------------------------------------------
- #pragma segment MAFileOpen
- short TVolume::GetVolRefNum()
- {
- return fFileSpec.vRefNum;
- }
- //----------------------------------------------------------------------------------------
- // TVolume::IsSameVolume: analog of IsSameFile
- //----------------------------------------------------------------------------------------
- #pragma segment MAFileOpen
- Boolean TVolume::IsSameVolume(TVolume* aVolume)
- {
-
- if (fFileSpec.vRefNum == aVolume -> GetVolRefNum())
- {
- CStr31 name;
-
- aVolume -> GetName(name);
- return (EqualString(*((CString *) fFileSpec.name), name, FALSE, TRUE));
- }
- return FALSE;
- }
- #pragma segment Inline